package com.firewolf.struts.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.firewolf.struts.forms.UserForm;

/**
 * 
 * @Description: 登录Action
 * @Author: 刘兴
 * @Date : 2016年8月25日
 * @package : com.firewolf.struts.filters
 * @Java_Version : 1.7
 * @Version : 2016年8月25日上午8:37:16
 */

public class UserAction extends Action {
	
	private int num = 0;
	

	/***
	 * 注意这个方法不要错了
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		num += 1;
		System.out.println("num : "+num);
		//从ActionForm中取出数据，
		UserForm userForm = (UserForm) form;
		System.out.println("用户："+userForm.getName());
		request.setAttribute("username", userForm.getName());
		//进行业务逻辑处理，从ActionMapping中获取
		if("123".equals(userForm.getPassword()))
			//返回跳转路径，
			return mapping.findForward("ok");
		return mapping.findForward("err");
	}
}
